package com.bsdk.install.device.constants;

import java.util.HashMap;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author sunjian0225@163.com
 * @version 1.0
 * @title IANALYSIS
 * @description
 * @create 2024/1/20 14:16
 */
public class LockConstants {

    //生成UID全局参数
    public static final AtomicLong COUNTER = new AtomicLong(System.currentTimeMillis());
    /**
     * 返回指令常量
     */
    public static final int STATUS_SUCCESS = 200; //请求正确，如开锁，下发各类指令

    public static final int STATUS_ERROR = 500; //指令错误

    //用户类型
    public static final int USER_TYPE_NORMAL = 00; //普通用户
    public static final int USER_TYPE_ADMIN =  01; //管理用户
    public static final int USER_TYPE_COERCE = 02; //挟持用户

    public static final int UN_RESPONSE = 100;//设备未响应
    public static final int USER_EXIST = 101; //用户存在
    public static final int USER_NOT_EXIST = 102; //用户不存在
    public static final int USER_TYPE_ERROR = 103; //用户类型错误

    public static final int USER_ID_EXCEED = 104; //用户Id错误
    public static final int USER_ADD_FAIL = 105; //添加用户失败

    public static final int USER_DELETE_FAIL = 106; //删除用户失败
    public static final int PASSWORD_EXCEED = 107; //密码长度错误

    public static final int PRINT_LENGTH_ERROR = 108; //指纹数据长度错误

    public static final int PRINT_CHECK_ERROR = 109; //指纹数据校验错误
    /**
     * 响铃
     */
    public static final int BELL_SOUND = 110; //响铃
    /**
     * 开锁
     */
    public static final int LOCK_OPEN = 111; //开锁

    //final int COMMAND_ERROR = 112; //指令错误
    public static final int TIME_SET_ERROR = 113; //时间错误

    public static final int FROZEN_FAIL = 114; //冻结失败
    public static final int PRINT_ID_NOT_EXIST = 115; //指纹ID不存在

    public static final int CIRCLE_MODE_ERROR = 116; //循环方式错误


    ////////////////////////上报code/////////////////
    /**
     * 本地请求远程开锁
     */
    public static final int REQEST_UNLOCK_REPORT = 120; //本地请求远程开锁
    /**
     * 添加密码用户上报
     */
    public static final int ADD_PW_USER_REPORT = 121; // 添加密码用户上报
    /**
     * 添加卡片用户上报
     */
    public static final int ADD_CARD_USER_REPORT = 122; // 添加卡片用户上报
    /**
     * 添加指纹用户上报
     */
    public static final int  ADD_FP_USER_REPORT = 123; // 添加指纹用户上报
    /**
     * 删除密码用户上报
     */
    public static final int DEL_PW_USER_REPORT = 124; // 删除密码用户上报
    /**
     * 删除卡用户上报
     */
    public static final int DEL_CARD_USER_REPORT = 125; // 删除卡用户上报
    /**
     * 删除指纹用户上报
     */
    public static final int DEL_FP_USER_REPORT = 126; // 删除指纹用户上报
    /**
     * 密码多次验证失败上报
     */

    public static final int VERIFY_PW_REPORT = 127; //密码多次验证失败上报
    /**
     * 卡多次验证失败上报
     */
    public static final int VERIFY_CARD_REPORT = 128; //卡多次验证失败上报
    /**
     * 指纹多次验证失败上报
     */
    public static final int VERIFY_FP_REPORT = 129; // 指纹多次验证失败上报
    /**
     * 防撬报警
     */
    public static final int ANTI_ALARM_REPORT = 130;  //防撬报警
    /**
     * 低电报警
     */

    public static final int LOWBAT_ALARM_REPORT = 131;  //低电报警
    /**
     * 劫持报警
     */

    public static final int ABDCT_ALRM_REPORT = 132;  //劫持报警
    /**
     * 多次输入，系统锁定
     */
    public static final int SYS_LOCKED_REPORT = 133; //多次输入，系统锁定
    /**
     * 复位上报要特殊处理
     */
    public static final int KEY_REMOTE_RESET_REPORT = 134;  //复位上报要特殊处理


    public static final int USER_CYCLE_TYPE_NONE = (byte)0xFF;//时间段无循环
    public static final int USER_CYCLE_TYPE_DAY = (byte)0x01;//时间段天循环
    public static final int USER_CYCLE_TYPE_WEEK = (byte)0x02;//时间段周循环
    public static final int USER_CYCLE_TYPE_MONTH = (byte)0x03;//时间段月循环

    public static final int USER_UNFROZEN_STATUS = (byte)0x00;//用户解冻状态
    public static final int USER_FROZEN_STATUS = (byte)0x01;//用户冻结状态

    /**
     * 错误码转换为文字
     */
    public static final HashMap<Integer,String> RsCodeToStr = new HashMap<Integer,String>(){{
        put(STATUS_ERROR,"设备未响应");
        put(USER_EXIST,"用户已存在");
        put(USER_NOT_EXIST,"用户不存在");
        put(USER_TYPE_ERROR,"用户类型错误");
        put(USER_ID_EXCEED,"用户ID错误");
        put(USER_ADD_FAIL,"添加用户失败");
        put(USER_DELETE_FAIL,"删除用户失败");
        put(PASSWORD_EXCEED,"密码长度错误");
        put(PRINT_LENGTH_ERROR,"指纹数据长度错误");
        put(PRINT_CHECK_ERROR,"指纹数据较验错误");
        put(BELL_SOUND,"门铃已响");
        put(LOCK_OPEN,"门锁开启");
        put(TIME_SET_ERROR,"时间错误");
        put(FROZEN_FAIL,"冻结失败");
        put(PRINT_ID_NOT_EXIST,"指纹ID不存在");
        put(CIRCLE_MODE_ERROR,"循环方式错误");
        put(VERIFY_PW_REPORT,"密码多次验证失败");
        put(VERIFY_CARD_REPORT,"卡多次验证失败");
        put(VERIFY_FP_REPORT,"指纹多次验证失败");
        put(LOWBAT_ALARM_REPORT,"低电量");
        put(ANTI_ALARM_REPORT,"门锁被撬");

    }
    };
    /**
     * 指令常量
     */

    //接收状态
    public final int CMD_RECEIVE_HEAD = 0x00;
    public final int CMD_RECEIVE_LEN = 0x01;
    public final int CMD_RECEIVE_PACKET_TYPE = 0x02;
    public final int CMD_RECEIVE_CMD_DATA = 0x03;
    public final int CMD_RECEIVE_CRC = 0x04;
    public final int CMD_RECEIVE_TAIL = 0x05;
    public final int CMD_RECEIVE_OK = 0x06;


    //包的类型
    public final byte PACKET_TYPE_SERVER_REQ = (byte) 0x80;//服务器发给锁的请求
    public final byte PACKET_TYPE_LOCK_RESP = (byte) 0x86;//锁应答服务器的响应
    public final byte TYPE_LOCK_SERVER_NORESPONE = (byte) 0x7F;  //锁发给服务器，不应答

    //锁的命令
    public final byte CMD_REMOTE_UNLOCK_REQ = (byte) 0x30;//远程开锁
    public final byte CMD_ADDPASS_BY_ID_REQ = (byte) 0x3E;//添加修改密码用户 0X3E

    public final byte CMD_DIS_ENABLE_BY_ID_REQ = (byte) 0x3C;//通过用户编号冻结、解冻用户 0x3c
    public final byte CMD_DELPASS_BY_ID_REQ = (byte) 0x38;//通过ID删除用户　　0x38
    public final byte CMD_MODIPASS_BY_ID_REQ = (byte) 0x42;//通过ID修改密码    0x42
    public final byte CMD_MODIVALID_BY_ID_REQ = (byte) 0x41;//通过ID修改有效期　　0x41
    public final byte CMD_ADD_ADMIN_PASSWORD_REQ = (byte) 0x3D;//下发临时　　0x3D

    public final byte CMD_ADJUST_TIME_REQ = (byte) 0x3A;//下发校准时间  0x3A


    ////////////////////////////上报////////////////////////////////////////////////////
    public final byte CMD_RING_REPORT = (byte) 0x30;//门铃上报
    public final byte CMD_REQEST_UNLOCK_REPORT = (byte) 0x31;//本地请求远程开锁
    public final byte CMD_UNLOCK_RECORD_REPORT = (byte) 0x32;//开门记录上报
    public final byte CMD_ADD_PW_USER_REPORT = (byte) 0x34;// 添加密码用户上报
    public final byte CMD_ADD_CARD_USER_REPORT = (byte) 0x36;// 添加卡片用户上报
    public final byte CMD_ADD_FP_USER_REPORT = (byte) 0x38;// 添加指纹用户上报
    public final byte CMD_DEL_PW_USER_REPORT = (byte) 0x35;// 删除密码用户上报
    public final byte CMD_DEL_CARD_USER_REPORT = (byte) 0x37;// 删除卡用户上报
    public final byte CMD_DEL_FP_USER_REPORT = (byte) 0x39;// 删除指纹用户上报
    public final byte CMD_VERIFY_PW_REPORT = (byte) 0x44;//密码多次验证失败上报
    public final byte CMD_VERIFY_CARD_REPORT = (byte) 0x45;//卡多次验证失败上报
    public final byte CMD_VERIFY_FP_REPORT = (byte) 0x46;// 指纹多次验证失败上报

    public final byte CMD_ANTI_ALARM_REPORT = (byte) 0x48;//防撬报警
    public final byte CMD_LOWBAT_ALARM_REPORT = (byte) 0x49; //低电报警
    public final byte CMD_ABDCT_ALRM_REPORT = (byte) 0x4A; //劫持报警
    public final byte CMD_SYS_LOCKED_REPORT = (byte) 0x4B;//多次输入，系统锁定
    public final byte CMD_KEY_REMOTE_RESET_REPORT = (byte) 0x4C;//复位 远程和本地复位都上报

////////////////////////////////////////////////////////////////////////////////////////////

    //模块的通讯协议
    public final int MOUDLE_CMD_RECEIVE_HEAD = 0x00;
    public final int MOUDLE_CMD_RECEIVE_LEN1 = 0x01;
    public final int MOUDLE_CMD_RECEIVE_LEN2 = 0x02;
    public final int MOUDLE_CMD_RECEIVE_CMD_DATA = 0x04;
    public final int MOUDLE_CMD_RECEIVE_CRC = 0x05;
    public final int MOUDLE_CMD_RECEIVE_TAIL = 0x06;
    public final int MOUDLE_CMD_RECEIVE_OK = 0x07;

    public final byte MOUDLE_CMD_REGIST_RESP = (byte) (0x77+0x80);//Regist 指令
    public final byte MOUDLE_CMD_PING_RESP = (byte) (0x78+0x80);//ping 指令
    public final byte MOUDLE_CMD_SET_REGIST_RESP = (byte) (0x7E+0x80);//Regist 指令
    public final byte MOUDLE_CMD_REQ_PING_RESP = (byte) (0x7F+0x80);//查询


}
